package com.koron.system.configSettings.post.controller;

import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.bean.system.post.po.PostUserPo;
import com.koron.bean.system.post.query.PostUserFilterQuery;
import com.koron.bean.system.post.query.PostUserQuery;
import com.koron.bean.system.post.vo.PostUserVo;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.system.configSettings.post.service.PostUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * (PostUser)表控制层
 *
 * @author zhouj
 * @since 2022-01-10 10:13:33
 */
@Api(tags = "岗位关联人员")
@RestController
@RequestMapping("/postUser/")
public class PostUserController {

    @Autowired
    private PostUserService postUserService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改")
    @PostMapping("insertOrUpdate")
    public Response insertOrUpdate(@RequestBody PostUserPo postUser) {
        return Response.ok(postUserService.insertOrUpdate(postUser));
    }

    @ApiOperation(value = "新增")
    @PostMapping("insert")
    public Response insert(@RequestBody PostUserPo postUser) {
        return Response.ok(postUserService.insert(postUser));
    }

    @ApiOperation(value = "批量新增")
    @PostMapping("insertBatch")
    public Response insertBatch(@RequestBody List<PostUserPo> postUserList) {
        return Response.ok(postUserService.insertBatch(postUserList));
    }

    @ApiOperation(value = "根据id更新")
    @PutMapping("update")
    public Response update(@RequestBody PostUserPo postUser) {
        return Response.ok(postUserService.update(postUser));
    }

    @ApiOperation(value = "根据id删除")
    @DeleteMapping("deleteById")
    public Response deleteById(String id) {
        return Response.ok(postUserService.deleteById(id));
    }

    @ApiOperation(value = "根据id查询")
    @GetMapping("queryById")
    public Response queryById(String id) {
        return Response.ok(postUserService.queryById(id));
    }

    @ApiOperation(value = "不分页查询列表")
    @GetMapping("queryList")
    public Response<List<PostUserVo>> queryList(PostUserQuery query) {
        return Response.ok(postUserService.queryList(query));
    }

    @ApiOperation(value = "不分页查询列表")
    @PostMapping("postqueryList")
    public Response<List<PostUserVo>> postqueryList(@RequestBody PostUserQuery query) {
        return Response.ok(postUserService.queryList(query));
    }

    @ApiOperation(value = "分页查询列表")
    @GetMapping("queryPageList")
    public Response queryPageList(PostUserQuery query, PageQuery pageQuery) {
        return Response.ok(postUserService.queryPageList(query, pageQuery));
    }

    @ApiOperation(value = "组合条件查询")
    @PostMapping("filterUser")
    public Response filterUser(@RequestBody List<PostUserFilterQuery> filterQueryList) {
        return Response.ok(postUserService.filterUser(filterQueryList));
    }

}
